home *** CD-ROM | disk | FTP | other *** search
/ Macademic for Students & Teachers / Macademic for Students and Teachers (Quantum Leap)(1992).iso / Fun & Games / ColorBoxes / ColorBoxes.pas < prev   
Encoding:
Pascal/Delphi Source File  |  1987-04-27  |  902 b   |  43 lines  |  [TEXT/TPAS]

  1. Program ColorBoxes_by_Neal_Trautman;
  2.  
  3. uses Memtypes,QuickDraw,OSIntf,ToolIntf;
  4.  
  5. Var rct : Rect;
  6.     i,l,t,r,b,ww,wh : Integer;
  7.  
  8. function randomize(x : integer) : integer;
  9. var x2 : longint;
  10. begin
  11.   x2 := abs(random);
  12.   randomize := (x2 * x) div 32768;
  13. end;
  14.  
  15. begin
  16.   ww := 512;
  17.   wh := 342;
  18.   repeat
  19.     l := randomize(ww);
  20.     t := randomize(wh);
  21.     r := randomize (ww);
  22.     b := randomize(wh);
  23.     setrect(rct,l,t,r,b);
  24.     i := randomize(20);
  25.     if i < 10 then
  26.         begin
  27.           case i of
  28.           1 : forecolor(whitecolor);
  29.           2 : forecolor(redcolor);
  30.           3 : forecolor(greencolor);
  31.           4 : forecolor(bluecolor);
  32.           5 : forecolor(cyancolor);
  33.           6 : forecolor(magentacolor);
  34.           7 : forecolor(yellowcolor);
  35.           otherwise forecolor(blackcolor);
  36.           end;
  37.           paintrect(rct);
  38.         end
  39.       else invertrect(rct);
  40.   until button;
  41. end.
  42.  
  43.